package fun.util.daohelper;

import fun.util.daohelper.expression.SearchExpression;

import java.util.List;
import java.io.Serializable;

/**
 * Author: bin
 * Date: Jan 9, 2006
 * Time: 10:28:36 PM
 */
public interface DaoHelper<D> {

    /**
     *
     * @param type - type of data to find
     * @param key  - key of data
     * @return found object
     */
    public D find( Class<? extends D> type, Serializable key );

    public void save( D... objectsToSave );

    public <F extends D> List<F> findAll(Class<F> type);

    public List<D> findByFields(Class<? extends D> dataType, SearchExpression... expressions);

    public D findUniqueByFields(Class<? extends D> dataType, SearchExpression... expressions);

    public int countByFields(Class<? extends D> dataType, SearchExpression... expressions);

    public void remove( D data );

    /**
     *
     * @param dataType    -
     * @param expressions -
     * @return number of removed objects
     */
    public int removeByFields( Class<? extends D> dataType, SearchExpression... expressions );

    public D removeById(Class<? extends D> type, Serializable key);

    public int removeAll( Class<? extends D> type );
}